package com.nsyue.auth.controller;

import com.nsyue.auth.controller.result.Result;
import com.nsyue.auth.service.UserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户表(User)表控制层
 *
 * @author laixm
 * @since 2023-05-08 16:48:40
 */
@RestController
public class UserController {
    /**
     * 服务对象
     */
    @Resource
    private UserService userService;

    @GetMapping("/api/user")
    @PreAuthorize("hasAnyAuthority('sys:user:list')")
    public Result<?> userInfo() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return Result.ok(authentication);
    }
}

